import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.omg.CosNaming.IstringHelper;

import de.fhwgt.dionarap.model.objects.AbstractPawn;
import de.fhwgt.dionarap.model.objects.Ammo;
import de.fhwgt.dionarap.model.objects.Destruction;
import de.fhwgt.dionarap.model.objects.Opponent;
import de.fhwgt.dionarap.model.objects.Player;
import de.fhwgt.dionarap.model.objects.Vortex;


public class Spielflaeche extends JPanel
{
	private JLabel[][] label;
	
	Spielflaeche()
	{
		System.out.println("--Spielfläche--");
		this.setLayout(new GridLayout(10,10));
		
		this.label = new JLabel[10][10];
		
		for(int zeile = 0; zeile < label.length; zeile++)
		{
			for(int reihe = 0; reihe < label.length; reihe++)
			{
				int modu = (zeile%2) + (reihe%2);
				if(modu == 0 || modu == 2)
				{
					this.label[zeile][reihe] = new JLabel();
					this.label[zeile][reihe].setBackground(Color.black);
					this.label[zeile][reihe].setPreferredSize(new Dimension(50,50));
					this.label[zeile][reihe].setOpaque(true);
				}else
				{
					this.label[zeile][reihe] = new JLabel();
					this.label[zeile][reihe].setBackground(Color.white);
					this.label[zeile][reihe].setPreferredSize(new Dimension(50,50));
					this.label[zeile][reihe].setOpaque(true);
				}
				this.add(this.label[zeile][reihe]);
			}
		}

		this.setVisible(true);
	}
	
	public void setGameElement(AbstractPawn _gameElement)
	{
		if(_gameElement instanceof Player)
		{
			this.label[_gameElement.getX()][_gameElement.getY()].setText("P");
		}else if(_gameElement instanceof Opponent)
		{
			this.label[_gameElement.getX()][_gameElement.getY()].setText("O");
		}else if(_gameElement instanceof Vortex)
		{
			this.label[_gameElement.getX()][_gameElement.getY()].setText("V");
		}else if(_gameElement instanceof Ammo)
		{
			this.label[_gameElement.getX()][_gameElement.getY()].setText("A");
		}else if(_gameElement instanceof Destruction)
		{
			this.label[_gameElement.getX()][_gameElement.getY()].setText("D");
		}
	}
	
	public void clearSpielflaeche()
	{
		for(int zeile = 0; zeile < label.length; zeile++)
		{
			for(int reihe = 0; reihe < label.length; reihe++)
			{
				
			}
		}
	}
}
